#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;

class Solution {
public:
    int maxLength(vector<int>& arr) {
        unordered_map<int, int> hash;
        int left = 0, right = 0;
        int len = arr.size();
        int maxi = 0;
        while (right < len)
        {
            hash[arr[right]]++;
            while (hash[arr[right]] != 1)
            {
                hash[arr[left]]--;
                if (hash[arr[left]] == 0) hash.erase(arr[left]);
                left++;
            }
            maxi = max(maxi, right - left + 1);
            right++;
        }
        return maxi;
    }
};

int main()
{
    return 0;
}